package com.platform.modules.sys.controller;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.common.annotation.SysLog;
import com.platform.common.utils.RestResponse;
import com.platform.modules.sys.service.SysUserTokenService;

/**
 * 系统用户TokenController
 *
 * @author 肖亮
 */
@RestController
@RequestMapping("sys/usertoken")
public class SysUserTokenController {
	@Autowired
	private SysUserTokenService sysUserTokenService;

	/**
	 * 分页查询qa
	 *
	 * @param params
	 *            查询参数
	 * @return RestResponse
	 */
	@PostMapping("/list")
	@RequiresPermissions("sys:usertoken:list")
	public RestResponse list(Map<String, Object> params) {
		Page page = sysUserTokenService.queryPage(params);

		return RestResponse.success().put("page", page);
	}

	/**
	 * 批量下线用户(删除用户token记录)
	 *
	 * @param userIds
	 *            userIds
	 * @return RestResponse
	 */
	@SysLog("批量下线用户")
	@RequestMapping("/offline")
	@RequiresPermissions("sys:usertoken:offline")
	@ResponseBody
	public RestResponse offline(String[] userIds) {
		sysUserTokenService.offlineBatch(userIds);
		return RestResponse.success();
	}
}
